import request from "@/utils/request"
import type { AttrInfoModel, AttrListModel } from "./model/attrModel"
import type { CategoryIdsModel } from "./model/categoryModel"

enum Api {
  getAttrListApi = "/admin/product/attrInfoList",
  deleteAttrApi = "/admin/product/deleteAttr",
  addOrUpdateAttrApi = "/admin/product/saveAttrInfo",
}

export const reqGetAttrListData = ({
  category1Id,
  category2Id,
  category3Id,
}: CategoryIdsModel) =>
  request.get<any, AttrListModel>(
    Api.getAttrListApi + `/${category1Id}/${category2Id}/${category3Id}`
  )

export const reqDeleteAttrApi = (attrId: number) =>
  request.delete<any, null>(Api.deleteAttrApi + `/${attrId}`)

export const reqAddOrUpdateAttrApi = (attrInfo: AttrInfoModel) =>
  request.post<any, null>(Api.addOrUpdateAttrApi, attrInfo)
